msp430-libc_version := 20120224

origin_src_tarball := msp430-libc-$(msp430-libc_version).tar.bz2
origin_src_dir := msp430-libc-$(msp430-libc_version)
repo := http://sourceforge.net/projects/mspgcc/files/msp430-libc/$(origin_src_tarball)

all:
	@echo NOTHING

build: sources/configure.sed
	@($(MAKE) $(MFLAGS) -C sources/src)

sources/configure.sed: sources
	@cd sources && \
	./configure --enable-ieee754-errors --prefix=$(INSTALL_DIR)

.PHONY:init
init: sources
sources: $(origin_src_tarball)
	@echo extracting files...
	@tar xmf $(origin_src_tarball) && \
	mv $(origin_src_dir) sources
	@echo extract files done

$(origin_src_tarball):
	@wget -c -O $(origin_src_tarball) $(repo);

patch:
# NOT NEEDED
unpatch:
# DO NOTHING

clean:
	#TODO: clean msp430-libc

distclean: clean
	@$(RM) -r sources

distdistclean: distclean
	@$(RM) $(origin_src_tarball)

install:
	@($(MAKE) $(MFLAGS) -C sources/src install)

uninstall:
	# TODO: uninstall msp430-libc
